<h1>My participation</h1>
<%@sum=0%>
<%if session[:role] == 0 %>
	<table border=1>
	
	  <tr>
		<th>Event</th>
	    <th>Date</th>
		<th>Place</th>
		<th>Fees</th>
		<th>Action</th>	
		
	  </tr> 
	 
	<% for event in @attendances %>
	  <tr>
	     <td><%=h event.name %></td>
		  <td><%=h event.date %></td>
		   <td><%=h event.place %></td>
		   <td><%=h event.fees %>€</td>
		   <%@sum=@sum+event.fees%>
	 
	    <td><%= link_to 'Show', :action => 'show', :id => event %></td>
	  </tr>
	<% end %>
	
	<tr>
		<th>Total fees</th>
		<th colspan="4"><%=@sum%>€</th>
	</tr>
	</table>
	
	
	
	<%= link_to 'Previous page', { :page => @attendance_pages.current.previous } if @attendance_pages.current.previous %>
	<%= link_to 'Next page', { :page => @attendance_pages.current.next } if @attendance_pages.current.next %> 
	
	<br />
<%else%>
	<table border=1>
	
	  <tr>
		<th>Event</th>
	    <th>Date</th>
		<th>Place</th>
		<th>Fees</th>				
	  </tr>
	  
	<% for event in @attendances %>
	  <tr>
	     <td><%=h event.name %></td>
		  <td><%=h event.date %></td>
		   <td><%=h event.place %></td>
		   <td>4€</td>
		   <%@sum=@sum+1%> 
	   
	  </tr>
	<% end %>
	
	<tr>
		<th>Total fees</th>
		<th colspan="3"><%=4*@sum%>€</th>
	</tr>
	</table>
	
	
	
	<%= link_to 'Previous page', { :page => @attendance_pages.current.previous } if @attendance_pages.current.previous %>
	<%= link_to 'Next page', { :page => @attendance_pages.current.next } if @attendance_pages.current.next %> 
	
	<br />
<% end %>

